package com.ylzinfo.channelclient.config;

import com.github.lianjiatech.retrofit.spring.boot.core.Constants;
import com.github.lianjiatech.retrofit.spring.boot.core.SourceOkHttpClientRegistrar;
import com.github.lianjiatech.retrofit.spring.boot.core.SourceOkHttpClientRegistry;
import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 陈添明
 * @since 2022/5/24 9:29 下午
 */
@Slf4j
@Component
public class CustomSourceOkHttpClientRegistrar implements SourceOkHttpClientRegistrar {
    @Resource
    private OkHttpClient defaultBaseOkHttpClient;

    @Override
    public void register(SourceOkHttpClientRegistry registry) {

        // 替换默认的SourceOkHttpClient
        registry.register(Constants.DEFAULT_SOURCE_OK_HTTP_CLIENT, defaultBaseOkHttpClient);
    }
}
